﻿$(document).ready(function () {
    if ($(".ddlChuyenMuc").val() == "2") {
        $(".fu-lich-khai-giang").show();
    } else { $(".fu-lich-khai-giang").hide(); }

    $(".ddlChuyenMuc").change(function () {
        //hide social worker and sponsor stuff
        if ($(this).val() == "2") {
            $(".fu-lich-khai-giang").show();
        } else { $(".fu-lich-khai-giang").hide(); }
    });
});

function xCheckForm() {
    var countErr = 0;
    //resset error
    $('.error-item').each(function () {
        $(this).removeClass("error-item");
    });
    //Check error
    if ($('.ddlChuyenMuc').val() == "0") {
        $('.ddlChuyenMuc').addClass("error-item");
        countErr++;
    }
    
    //Check error
    if ($('.ddlChuyenMucLienQuan').val() == "0") {
        $('.ddlChuyenMucLienQuan').addClass("error-item");
        countErr++;
    }
    //Check error
    if ($('.ddlAuthor').val() == "0") {
        $('.ddlAuthor').addClass("error-item");
        countErr++;
    }

    if ($.trim($('.txtTieuDe').val()) == "") {
        $('.txtTieuDe').errorItem('Vui lòng nhập tiêu đề.');
        countErr++;
    }

    if (countErr > 0) {
        $('html,body').animate({ scrollTop: ($(".error-item").offset().top - 10) }, 'slow');
        return false;
    }
    else return true;
}